const mongoose = require('./db')
const UserSchema = mongoose.Schema({
    username: String,
    password: String,
    phone: String,
    avatar: String,
    gender: String,
    age: Number,
    vip: Number,
    tribeId: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Tribe'
    },
    data: String,
    label: Array,
    key: Number
})
const User = mongoose.model('User', UserSchema, 'User')

const TribeSchema = mongoose.Schema({
    name: String,
    energy: Number,
    icons: String,
})

const cateListModel = mongoose.model('Catelist', cateList, 'Catelist')
const MvListModel = mongoose.model('Mvlist', MvList, 'Mvlist')

const commentSchema = new mongoose.Schema({
    name: String,         // 评论者姓名
    content: String,      // 评论内容
    parent: {           // 父评论引用
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Tribe',
        default: null
    },
});


module.exports = {
    cateListModel,
    MvListModel,
    Comment,
    User
}

const Tribe = mongoose.model('Tribe', TribeSchema, 'Tribe')


const messageSchema = mongoose.Schema(
    {
        message: {
          text: { type: String, required: true },
        },
        users: Array,
        sender: {
          type: mongoose.Schema.Types.ObjectId,
          ref: "User",
          required: true,
        },
      },
      //时间戳
      {
        timestamps: true,
      }
)
const Message = mongoose.model('Message', messageSchema, 'Message')

const AIMesSchema=mongoose.Schema({
  fromSelf:Boolean,
  message:String,
})
const AIMessage = mongoose.model('AIMessage', AIMesSchema, 'AIMessage')


module.exports = { User, Tribe,Message, AIMessage}

// ················留言数据················
let ReleaseSchema = new mongoose.Schema({
    content: String,
    date: {
        type: Date,
        default: Date.now()
    },
    release: {
        type: Boolean,
        default: false
    },
    isNo:{
        type:Number,
        default:0
    }

})

//··············收藏数据·····················
const cateList = new mongoose.Schema({
    title: String,
    image: String,
    desc: String,
    cid: Number
})
const MvList = new mongoose.Schema({
    title: String,
    cid: Number,
    desc: String,
    images: Array,
    classList: Array,
    path:String
})




let Release = mongoose.model('Release', ReleaseSchema, 'Release')

module.exports = { Release,MvListModel }
